<template>
  <div class="toplist">
    <h2>排行榜</h2>
    <div class="topContent">
      <div class="top" v-for="(item, index) in topText" :key="index">
        <span>{{ item.name }}</span>
        <span class="line"></span>
        <ul v-for="(j, i) in topSongList[index]" :key="i">
          <li @click="debounceMethods(searchSong,j.id)">{{ i + 1+"\u00A0" }}:{{ "\u00A0\u00A0" }}{{ j.name }}</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import { topSong, songListDetail } from "@/api/api.js";
export default {
  name: "toplist",
  data() {
    return {
      topText: [],
      topParams: { id: null },
      isEnadle: false,
      topSongList: [],
    };
  },
  mounted() {
    this.getTop();
  },
  methods: {
    getTop() {
      let _this = this;
      topSong().then((res) => {
        _this.topText = res.data.list.splice(0, 4);
        _this.topText.forEach((e) => {
          songListDetail({ id: e.id }).then((r) => {
            let obj = r.data.playlist.tracks.splice(0, 10);
            _this.topSongList.push(obj);
          });
        });
      });
    },
    searchSong(v) {
      this.getMusic(v)
    },
  },
};
</script>

<style lang='less' scoped>
.toplist {
  width: 1200px;
  margin-top: 40px;

  h2 {
    font-family: "hmB";
    font-size: 28px;
    color: rgb(68, 68, 68);
    text-align: center;
    margin-bottom: 20px;
  }

  .topContent {
    width: 1200px;
    height: 500px;
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: space-between;
    background-size: 100%;

    .top {
      width: 260px;
      border-radius: 5px;
      transition: all 0.2s linear;

      &:hover {
        transform: scale(1.025);
      }

      &:nth-child(1) {
        background: #f14c7ef8 url("../../../assets/images/bg_index_top.5314c494.webp") no-repeat center center/500% auto;
        background-blend-mode: Overlay;
      }

      &:nth-child(2) {
        background: #008367d7 url("../../../assets/images/bg_index_top.5314c494.webp") no-repeat center center/500% auto;
        background-blend-mode: Overlay;
      }

      &:nth-child(3) {
        background: #1536a3bd url("../../../assets/images/bg_index_top.5314c494.webp") no-repeat center center/500% auto;
        background-blend-mode: Overlay;
      }

      &:nth-child(4) {
        background: #681fc7a4 url("../../../assets/images/bg_index_top.5314c494.webp") no-repeat center center/500% auto;
        background-blend-mode: Overlay;
      }

      ul {
        width: 200px;
        margin: 0 auto;
        li {
          width: 200px;
          margin: 15px auto;
          height: 25px;
          color: #fff;
          font-size: 14px;
          font-family: "hmR";
          overflow: hidden;
          transition: all 0.2s linear;
          line-height: 25px;
          border-radius: 5px;
           padding-left: 5px;
          cursor: pointer;

          &:hover {
            transition: all 0.2s linear;
            background-color: rgba(255, 255, 255, 0.377);
          }
        }
      }
    }

    .line {
      width: 80px;
      height: 4px;
      display: block;
      margin: 10px auto;
      background-color: #fff;
    }

    span {
      display: inline-block;
      font-family: "hmB";
      font-size: 28px;
      color: #fff;
      width: 100%;
      text-align: center;
      margin: 25px 0 auto;
    }
  }
}
</style>